window._ = require('lodash');

require('./services/prototypes');
window.jQuery = require('jquery')
require('bootstrap')
window.Cookies = require('js-cookie');
window.Url = require('url')

import LeUtils from  './services/le-utils'
window.LeUtils = LeUtils;

import LeDisplay from './services/le-display'
window.LeDisplay = LeDisplay;

import LeStorage from './services/le-storage'
window.LeStorage = LeStorage;

import Axios from  './services/axios'
window.Axios = Axios;

import LeRoute from "./services/le-route";
window.LeRoute = LeRoute

import LeValidator from "./services/le-validators";
window.LeValidator = LeValidator

/*if(window.Url.parse()){

}*/

import Vue from  'vue'
Vue.prototype.$LeRoute = LeRoute
Vue.prototype.$LeUtils = LeUtils
Vue.prototype.$LeDisplay = LeDisplay
Vue.prototype.$LeStorage = LeStorage
Vue.prototype.$windowReload = function () {
    window.location.reload();
}
Vue.prototype.$joinToString = function (obj, glue) {
    return LeUtils.joinToString(obj, glue)
}
window.Vue = Vue;
import ElementUI from 'element-ui'
import locale from 'element-ui/lib/locale/lang/zh-CN'
window.Vue.use(ElementUI, { locale });
import VueClipboard from 'vue-clipboard2'

Vue.use(VueClipboard)


require('./extend-components-register')

export default {
    Vue:function(options){
        if(!LeUtils.typeIs('object',options)){
            options = {
                el: '#app',
            }
        }

        window.VueApp = new window.Vue(options);
        window.VueApp.$nextTick(function () {
            jQuery("#page-loading").remove();
            jQuery("#app").removeClass('d-none');
        })
        window.LeExtendMessageHandle = function (msg,type){
            if('error' == type){
                window.VueApp.$message.error(msg);
            }else if('success' == type){
                window.VueApp.$message.success(msg);
            }else if('warning' == type){
                window.VueApp.$message.warning(msg);
            }else{
                window.VueApp.$message.info(msg);
            }
        }
        return window.VueApp;
    },
    init: async function(){
        ///await LeRoute.initCache()
        return this
    }
}


